﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using DAO;
namespace BUS
{
    public class CommentBUS
    {
        public static List<COMMENT> GetComment(int IDProduct)
        {
            try
            {
                bool isExiting = CommentDAO.IsExistingByProduct(IDProduct);
                List<COMMENT> ListComment = new List<COMMENT>();
                if (!isExiting)
                    return ListComment;                
                ListComment=CommentDAO.GetComment(IDProduct);
                return ListComment;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static bool Insert(COMMENT Comment)
        {
            try
            {
                return CommentDAO.Insert(Comment);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static void Update(COMMENT Comment)
        {
            try
            {
                bool isExist = CommentDAO.IsExisting(Comment.IDCOMMENT);
                if (!isExist)
                    return;
                CommentDAO.Update(Comment);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static bool Delete(int idComment)
        {
            try
            {
                bool isExist = CommentDAO.IsExisting(idComment);
                if (!isExist)
                    return false;
                return CommentDAO.Delete(idComment);
            }
            catch(Exception ex)
            {
                throw ex;
            }
        }
       
    }
}
